package tantque;

public class WhileThree implements IFermeture {

    private final IPredicat B1,  B2,  B3;
    private final IFermeture succ1,  succ2,  succ3;
    private final IFermeture E;

    public static IFermeture getInstance(IPredicat B1, IPredicat B2, IPredicat B3, IFermeture succ1, IFermeture succ2, IFermeture succ3, IFermeture E) {
        return new WhileThree(B1, B2, B3, succ1, succ2, succ3, E);
    }

    private WhileThree(IPredicat B1, IPredicat B2, IPredicat B3, IFermeture succ1, IFermeture succ2, IFermeture succ3, IFermeture E) {
        this.B1 = B1;
        this.B2 = B2;
        this.B3 = B3;
        this.succ1 = succ1;
        this.succ2 = succ2;
        this.succ3 = succ3;
        this.E = E;
    }

    @Override
    public void executer() {
        while (B1.evaluer()) {
            while (B2.evaluer()) {
                while (B3.evaluer()) {
                    E.executer();
                    succ3.executer();
                }
                succ2.executer();
            }
            succ1.executer();
        }
    }
}
